package cn.ac.siom.query.dao.impl;


import cn.ac.siom.query.dao.IP_basicDAO;
import cn.ac.siom.query.vo.P_basic;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Repository
public class P_basicDAOImpl extends SqlSessionDaoSupport implements IP_basicDAO {
    @Autowired
    public P_basicDAOImpl(SqlSessionFactory sqlSessionFactory){
        super.setSqlSessionFactory(sqlSessionFactory);
    }

    @Override
    public boolean doCreate(P_basic vo) throws SQLException {
        return false;
    }

    @Override
    public boolean doUpdate(P_basic vo) throws SQLException {
        return false;
    }

    @Override
    public boolean doRemove(Set<?> ids) throws SQLException {
        return false;
    }

    @Override
    public P_basic findById(Integer id) throws SQLException {
        return null;
    }

    @Override
    public List<P_basic> findAll() throws SQLException {
        return super.getSqlSession().selectList("P_basicNS.findAll");
    }

    @Override
    public List<P_basic> findAllBySplit(String column, String keyWord, Integer currentPage, Integer lineSize) throws SQLException {
        return null;
    }


    @Override
    public List<P_basic> findNo(Integer id) throws SQLException {
        Map<String, Integer> map= new HashMap<>();
        map.put("i_id",id);
        return super.getSqlSession().selectList("P_basicNS.findNo", map);
    }

    @Override
    public List<P_basic> findPage(Integer rownum, Integer page_id) throws SQLException {
        page_id = rownum * (page_id-1);
        Map<String, Integer> map= new HashMap<>();
        map.put("page_id",page_id);
        map.put("rownum",rownum);
        return super.getSqlSession().selectList("P_basicNS.findPage", map);
    }

    @Override
    public Integer findCount() throws SQLException {
        return super.getSqlSession().selectOne("P_basicNS.findCount");
    }

    @Override
    public List<P_basic> findHttp_Photo() throws SQLException {
        return super.getSqlSession().selectList("P_basicNS.findPhoto_Http");
    }
}
